package com.zs.exception.handller;

import com.zs.exception.UnCatchParamException;
import com.zs.exception.ValidateException;
import com.zs.util.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  异常处理
 * </p>
 * @Author: Shun
 * @CreateTime: 2019-07-17 21:41
 * @Emil: 381889220@qq.com
 */
@ControllerAdvice
public class ExceptionHandlers {

    @ExceptionHandler(value = UnCatchParamException.class)
    @ResponseBody
    public Result test1(){
        return new Result("缺少参数");
    }

    @ExceptionHandler(value = ValidateException.class)
    @ResponseBody
    public Result test2(){
        return new Result("表单数据不合格");
    }

}
